package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.base.result.R;
import com.atguigu.srb.core.service.LendService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-01-04
 */
@RestController
@RequestMapping("/admin/core/lend")
public class AdminLendController {
    @Resource
    LendService lendService;
    @ApiOperation("放款")
    @PutMapping("/makeLoan/{id}")
    public R makeLoan(@PathVariable("id")String id){
        lendService.makeLoan(id);
        return R.ok();
    }
    @ApiOperation("查询标的详情")
    @GetMapping("{id}")
    public R getById(@PathVariable("id")String id){
        Map<String,Object> map = lendService.getLendDetail(id);
        return R.ok().data("items" , map);
    }

    @ApiOperation("标的列表")
    @GetMapping
    public R list(){
        // 以后封装数据时 可以自定义VO类 也可以再原有类上扩展
        return R.ok().data("items",lendService.listLends());
    }

}

